/**
 * 全局设置
 */

var GLOBAL_CONFIG = {
     root: '/',
     hexoversion: '5.1.1',
     algolia: undefined,
     localSearch: undefined,
     translate: undefined,
     noticeOutdate: undefined,
     highlight: { "plugin": "highlighjs", "highlightCopy": true, "highlightLang": true },
     copy: {
       success: '复制成功',
       error: '复制错误',
       noSupport: '浏览器不支持'
     },
     bookmark: {
       message_prev: '按',
       message_next: '键将本页加入书签'
     },
     runtime: '',
     date_suffix: { "one_hour": "刚刚", "hours": "小时前", "day": "天前" },
     copyright: undefined,
     ClickShowText: undefined,
     medium_zoom: false,
     fancybox: true,
     Snackbar: undefined,
     justifiedGallery: {
       js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
       css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
     },
     baiduPush: false,
     isPhotoFigcaption: false,
     islazyload: false,
     isanchor: false
   };

   var saveToLocal = {
     set: function setWithExpiry(key, value, ttl) {
       const now = new Date()
       const expiryDay = ttl * 86400000
       const item = {
         value: value,
         expiry: now.getTime() + expiryDay,
       }
       localStorage.setItem(key, JSON.stringify(item))
     },

     get: function getWithExpiry(key) {
       const itemStr = localStorage.getItem(key)

       if (!itemStr) {
         return undefined
       }
       const item = JSON.parse(itemStr)
       const now = new Date()

       if (now.getTime() > item.expiry) {
         localStorage.removeItem(key)
         return undefined
       }
       return item.value
     }
   }
 